package com.onlinevideo.dao.impl;

import com.onlinevideo.dao.BaseDao;
import com.onlinevideo.dao.LoginfoDao;
import com.onlinevideo.entity.Loginfo;

import java.util.List;

public class LoginfoDaoImpl extends BaseDao implements LoginfoDao {
    @Override
    public int insert(Loginfo loginfo) {
        String sql ="INSERT INTO `T_loginfo` (`interview_time`,`url`,`interview_ip`,`operation`) VALUES (?,?,?,?)";
        return super.update(sql,loginfo.getInterviewTime(),loginfo.getUrl(),loginfo.getInterviewIp(),loginfo.getOperation());
    }

    @Override
    public int delete(Long id) {
        String sql = "DELETE FROM `T_loginfo` WHERE `id`=?";
        return super.update(sql,id);
    }

    @Override
    public int update(Loginfo loginfo) {
        String sql = "UPDATE `T_loginfo` SET `interview_time`=?,`url`=?,`interview_ip`=?,`operation`=? WHERE `id`=?";
        return super.update(sql,loginfo.getInterviewTime(),loginfo.getUrl(),loginfo.getInterviewIp(),loginfo.getOperation(),loginfo.getId());

    }

    @Override
    public Loginfo queryById(Long id) {
        String sql = "SELECT `id`,`interview_time` AS `interviewTime`,`url`,`interview_ip` AS `interviewIp`,`operation` FROM `T_loginfo` WHERE 1=1 AND `id`=?  ";
        return super.queryForOne(Loginfo.class,sql,id);
    }

    @Override
    public List<Loginfo> queryAll() {
        String sql = "SELECT `id`,`interview_time` AS `interviewTime`,`url`,`interview_ip` AS `interviewIp`,`operation` FROM `T_loginfo` WHERE 1=1 ";
        return super.queryForList(Loginfo.class,sql);
    }
}
